/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package project;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 *
 * @author jon
 */
public class Owner {
    private String owner_name;
    private String telephone_number;
    private String fax_number;
    private int owner_type;
    private String business_type;
    private String business_contact_name;

    public Owner(String owner_name, String telephone_number, String fax_number, int owner_type, String business_type, String business_contact_name) {
        this.owner_name = owner_name;
        this.telephone_number = telephone_number;
        this.fax_number = fax_number;
        this.owner_type = owner_type;
        this.business_type = business_type;
        this.business_contact_name = business_contact_name;
    }

    
    /**
     * @return the owner_name
     */
    public String getOwner_name() {
        return owner_name;
    }

    /**
     * @param owner_name the owner_name to set
     */
    public void setOwner_name(String owner_name) {
        this.owner_name = owner_name;
    }

    /**
     * @return the telephone_number
     */
    public String getTelephone_number() {
        return telephone_number;
    }

    /**
     * @param telephone_number the telephone_number to set
     */
    public void setTelephone_number(String telephone_number) {
        this.telephone_number = telephone_number;
    }

    /**
     * @return the fax_number
     */
    public String getFax_number() {
        return fax_number;
    }

    /**
     * @param fax_number the fax_number to set
     */
    public void setFax_number(String fax_number) {
        this.fax_number = fax_number;
    }

    /**
     * @return the owner_type
     */
    public int getOwner_type() {
        return owner_type;
    }

    /**
     * @param owner_type the owner_type to set
     */
    public void setOwner_type(int owner_type) {
        this.owner_type = owner_type;
    }

    /**
     * @return the business_type
     */
    public String getBusiness_type() {
        return business_type;
    }

    /**
     * @param business_type the business_type to set
     */
    public void setBusiness_type(String business_type) {
        this.business_type = business_type;
    }

    /**
     * @return the business_contact_name
     */
    public String getBusiness_contact_name() {
        return business_contact_name;
    }

    /**
     * @param business_contact_name the business_contact_name to set
     */
    public void setBusiness_contact_name(String business_contact_name) {
        this.business_contact_name = business_contact_name;
    }

    public void insert()
    {
        try
        {
            String host = "jdbc:oracle:thin:@localhost:1521:xe";
            String username = "jon";
            String password = "chaosecco";
            String driverName = "oracle.jdbc.driver.OracleDriver";
            Class.forName(driverName);

            Connection connection = DriverManager.getConnection(host,
                    username, password);
            System.out.print("Connected successfully.");
            String insertQuery = "INSERT INTO EMPLOYEE(" +
                    "owner_name, "  +
                    "telephone_number, " +
                    "fax_number, " +
                    "owner_type, " +
                    "business_type" +
                    "business_contact_name)" +
                    "VALUES(?, ?, ?, ?, ?, ?)";
            PreparedStatement ps = connection.prepareStatement(insertQuery);
            ps.setString(1, owner_name);
            ps.setString(2, telephone_number);
            ps.setString(3, fax_number);
            ps.setInt(4, owner_type);
            ps.setString(5, business_type);
            ps.setString(6, business_contact_name);
            ps.executeUpdate();

            connection.close();
        }

        catch (SQLException e)
        {
            System.out.println("ERROR: " + e.getMessage());
        }

        catch(ClassNotFoundException e)
        {
            System.out.println("ERROR: " + e.getMessage());
        }
    }
}